package com.hyfrogx.modules.sys.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyfrogx.common.utils.PageUtils;
import com.hyfrogx.common.utils.Query;
import com.hyfrogx.modules.sys.dao.SysLogDao;
import com.hyfrogx.modules.sys.entity.SysLogEntity;
import com.hyfrogx.modules.sys.service.SysLogService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * TODO SysLogService 实现类
 *
 * @author crazypenguin
 * @version 1.0.0
 * @createdate 2019/1/2
 */
@Service("sysLogService")
public class SysLogServiceImpl extends ServiceImpl<SysLogDao, SysLogEntity> implements SysLogService {

	@Override
	public PageUtils queryPage(Map<String, Object> params) {
		String key = (String) params.get("key");

		IPage<SysLogEntity> page = this.page(
				new Query<SysLogEntity>(params).getPage(),
				new QueryWrapper<SysLogEntity>().like(StrUtil.isNotBlank(key), "username", key).orderByDesc("create_date")
		);

		return new PageUtils(page);
	}
}
